#include <bits/stdc++.h>
using namespace std;
class Solution
{
public:
  int minimumCardPickup(vector<int> &cards)
  {
    unordered_map<int, int> um;
    int ans = INT_MAX;
    bool flag = false;
    for (int i = 0; i < cards.size(); i++)
    {
      if (um[cards[i]])
      {
        flag = true;
        ans = min(ans, i + 1 - um[cards[i]] + 1);
      }
      um[cards[i]] = i + 1;
    }
    return flag ? ans : -1;
  }
};
int main()
{
  Solution s;

  return 0;
}
